#include "polygon.h"
#include <dlfcn.h>
#include <iostream>
using namespace std;
typedef CPolygon *(*create_t)();

int main(int argc, char const* argv[])
{
	void *handle = dlopen("./triangle.so", RTLD_LAZY);
	if (!handle) {
		std::cerr<<dlerror()<<std::endl;
		return 1;
	}

	create_t _create = (create_t )dlsym(handle, "create");
	CPolygon *pobj = _create();
	if (NULL != pobj) {
		pobj->area();
	}
	delete pobj;
	dlclose(handle);
	
	return 0;
}
